package com.playball.lottery.nt.orjdd;

import com.playball.lottery.bean.APPOfAdvertisingBean;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;

/**
 * Created by Administrator on 2017/3/15.
 */

public class JsonUtil {


//获取广告位数据
    public static ArrayList<APPOfAdvertisingBean> getAdvertisingData(JSONObject json) {

        ArrayList<APPOfAdvertisingBean> beans = new ArrayList<APPOfAdvertisingBean>();
        try {
            JSONArray jsonArray = json.getJSONArray("Data");
            String isSuccess = json.getString("Code");
            if (isSuccess.equals("0")) {
                for (int i = 0; i < jsonArray.length(); i++) {
                    JSONObject jsonObj = jsonArray.getJSONObject(i);
                    APPOfAdvertisingBean bean = new APPOfAdvertisingBean();
                    bean.setTitle(jsonObj.getString("Title"));
                    bean.setLinkUrl(jsonObj.getString("LinkUrl"));
                    bean.setImgPath(jsonObj.getString("ImgPath"));
                    bean.setCreateTime(jsonObj.getString("CreateTime"));
                    bean.setTypeID(jsonObj.getString("TypeID"));
                    beans.add(bean);
                }
            }
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return beans;
    }
}
